import { getEnv } from "@/pages/common-menu/environment/service"
import { LoadingOutlined } from "@ant-design/icons"
import { useModel, useRequest } from "@umijs/max"

const BaseURL = ({ id }: any) => {
    const { initialState } = useModel('@@initialState')

    const { data, loading } = useRequest(() => {
        return getEnv({ id, projectId: initialState?.currentProject?.id })
    }, { ready: !!id, refreshDeps: [id] })

    return !loading ? (data ? <>{`${data?.protocol}://${data?.domain}`}</> : <>-</>) : <LoadingOutlined />

}

export default BaseURL
